#pragma once
#include <boost/asio.hpp>
#include <iostream>
class IOServicePool
{
public:
	using work_guard = boost::asio::executor_work_guard<boost::asio::io_context::executor_type>;
	using work_guard_ptr = std::unique_ptr<work_guard>;
	~IOServicePool();
	IOServicePool(const IOServicePool&) = delete;
	IOServicePool& operator=(const IOServicePool&) = delete;
	void stop();
	boost::asio::io_context& getIOC();
	static IOServicePool& GetInst();
private:
	IOServicePool(size_t size = std::thread::hardware_concurrency());
	std::vector<boost::asio::io_context> _iocs;
	std::vector<work_guard_ptr> _works;
	std::vector<std::thread> _threads;
	std::size_t _nextIoc;
};

